<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Chaxi License System - 启动器</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Microsoft YaHei', sans-serif;
            background: linear-gradient(135deg, #2c3e50 0%, #4ca1af 100%);
            min-height: 100vh;
            display: flex;
            justify-content: center;
            align-items: center;
            padding: 20px;
            color: #333;
        }

        .container {
            background: white;
            border-radius: 20px;
            box-shadow: 0 20px 60px rgba(0,0,0,0.3);
            padding: 40px;
            width: 100%;
            max-width: 700px;
            text-align: center;
        }

        h1 {
            font-size: 28px;
            margin-bottom: 10px;
            color: #2c3e50;
        }

        .subtitle {
            color: #666;
            margin-bottom: 30px;
            font-size: 16px;
        }

        .logo {
            font-size: 64px;
            margin-bottom: 20px;
        }

        .grid {
            display: grid;
            grid-template-columns: repeat(2, 1fr);
            gap: 20px;
            margin-top: 30px;
        }

        .card {
            background: #f8f9fa;
            border-radius: 12px;
            padding: 20px;
            text-align: center;
            transition: all 0.3s;
            cursor: pointer;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            min-height: 180px;
            border: 2px solid transparent;
        }

        .card:hover {
            transform: translateY(-5px);
            box-shadow: 0 10px 20px rgba(0,0,0,0.1);
            border-color: #4ca1af;
        }

        .card-icon {
            font-size: 48px;
            margin-bottom: 15px;
            color: #2c3e50;
        }

        .card-title {
            font-size: 18px;
            font-weight: 600;
            margin-bottom: 10px;
            color: #2c3e50;
        }

        .card-description {
            font-size: 14px;
            color: #666;
        }

        .footer {
            margin-top: 40px;
            color: #666;
            font-size: 14px;
        }

        .server-card {
            grid-column: span 2;
            background: linear-gradient(135deg, #e0f7fa 0%, #b2ebf2 100%);
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="logo">🔐</div>
        <h1>Chaxi License System</h1>
        <p class="subtitle">选择要启动的组件</p>

        <div class="grid">
            <div class="card server-card" onclick="startServer()">
                <div class="card-icon">🖥️</div>
                <div class="card-title">启动远程服务器</div>
                <div class="card-description">运行授权验证和管理服务器</div>
            </div>

            <div class="card" onclick="openAdminWeb()">
                <div class="card-icon">🔑</div>
                <div class="card-title">Web授权生成器</div>
                <div class="card-description">管理员用于生成授权码的Web界面</div>
            </div>

            <div class="card" onclick="openClientWeb()">
                <div class="card-icon">🔒</div>
                <div class="card-title">Web授权验证器</div>
                <div class="card-description">用户验证授权的Web界面</div>
            </div>

            <div class="card" onclick="openAdminElectron()">
                <div class="card-icon">⚡</div>
                <div class="card-title">Electron授权生成器</div>
                <div class="card-description">管理员用于生成授权码的桌面应用</div>
            </div>

            <div class="card" onclick="openClientElectron()">
                <div class="card-icon">🛡️</div>
                <div class="card-title">Electron授权验证器</div>
                <div class="card-description">用户验证授权的桌面应用</div>
            </div>
        </div>

        <div class="footer">
            <p>Copyright © 2025 Chaxi | License System v1.0.0</p>
        </div>
    </div>

    <script>
        const { shell, ipcRenderer } = require('electron');
        const path = require('path');
        const { exec } = require('child_process');

        function startServer() {
            ipcRenderer.send('start-server');
        }

        function openAdminWeb() {
            const adminPath = path.join(__dirname, 'admin', 'keygen.html');
            shell.openExternal(`file://${adminPath}`);
        }

        function openClientWeb() {
            const clientPath = path.join(__dirname, 'client', 'auth.html');
            shell.openExternal(`file://${clientPath}`);
        }

        function openAdminElectron() {
            exec(`electron "${path.join(__dirname, 'admin', 'electron-keygen.html')}"`, (error) => {
                if (error) {
                    console.error(`执行错误: ${error}`);
                    alert('启动失败: ' + error.message);
                }
            });
        }

        function openClientElectron() {
            exec(`electron "${path.join(__dirname, 'client', 'electron-auth.html')}"`, (error) => {
                if (error) {
                    console.error(`执行错误: ${error}`);
                    alert('启动失败: ' + error.message);
                }
            });
        }
    </script>
</body>
</html>
